//
//  ViewController.m
//  Login
//
//  Created by qineng on 16/1/8.
//  Copyright © 2016年 hunanqinengkeji. All rights reserved.
//

#import "ViewController.h"
#import "UIView+Frame.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //设置标题
    self.title = @"登陆";
    
   //初始化背景图
    UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 64, self.view.width, 200)];
    //设置图片
    bgImageView.image = [UIImage imageNamed:@"bg_icon_benjingtu"];
    //增加到当前视图
    [self.view addSubview:bgImageView];
 
    //初始化logo图
    UIImageView *logoImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,112, 66)];
    //设置图片
    logoImageView.image = [UIImage imageNamed:@"icon_qianhuilogo"];
    //添加到背景图上
    [bgImageView addSubview:logoImageView];
    
    //logo设置居中
    logoImageView.center = CGPointMake(bgImageView.width*0.5, bgImageView.height*0.5);
    
    //设置视图背景色为灰色
    self.view.backgroundColor = [UIColor colorWithRed:236/255.0 green:239/255.0 blue:242/255.0 alpha:1];
    
    //创建一个纺织输入框的容器View
    UIView *containView = [[UIView alloc] initWithFrame:CGRectMake(0, bgImageView.bottom+10, self.view.width, 83)];
    [self.view addSubview:containView];
    
    //设置容器View背景色为白色
    containView.backgroundColor = [UIColor whiteColor];
  
    //创建第一个灰色线条
    UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(0, 0, containView.width, 1)];
    topLine.backgroundColor = [UIColor grayColor];
    [containView addSubview:topLine];
    
    //创建手机号码输入框
    UITextField *phoneTextField = [[UITextField alloc] initWithFrame:CGRectMake(0, topLine.bottom, containView.width, 40)];
    
    //手机号码输入框添加容器View上面
    [containView addSubview:phoneTextField];
    
    //设置提示语
    phoneTextField.placeholder = @"请输入手机号码";
    
    //设置字体大小
    phoneTextField.font = [UIFont systemFontOfSize:14];
    
    //创建手机号码输入框左边的容器View
    UIView *phoneLeftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 90, phoneTextField.height)];
//    phoneLeftView.backgroundColor = [UIColor redColor];
    
    //手机号码输入框左边的容器View添加到左边
    phoneTextField.leftView = phoneLeftView;
    
    //设置手机号码输入框的显示模式(一直存在)
    phoneTextField.leftViewMode = UITextFieldViewModeAlways;
    
    //创建手机输入框左边的图片
    UIImageView *phoneImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 18, 18)];
    phoneImageView.image = [UIImage imageNamed:@"icon_zhanghao"];
    
    //设置phoneImageView的X位置
    phoneImageView.left = 10;
    
    //设置phoneImageViewY轴居中
    phoneImageView.centerY = phoneLeftView.height*0.5;
    
    //添加到phoneLeftView上面去
    [phoneLeftView addSubview:phoneImageView];
    
    //初始化手机号Label
    UILabel *phoneLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, phoneLeftView.height)];
    
    //设置文字
    
    
    phoneLabel.text = @"手机号:";
    
    //设置字体
    phoneLabel.font = [UIFont systemFontOfSize:15];
    
    //设置手机号Label的X位置
    phoneLabel.left = phoneImageView.right+5;
    
    //设置手机号Label的Y位置居中
    phoneLabel.centerY = phoneLeftView.centerY;
    
    //设置字体颜色
    phoneLabel.textColor = [UIColor colorWithRed:30/255.0 green:176/255.0 blue:81/255.0 alpha:1];
 
    //将phoneLabel添加到phoneLeftView上
    [phoneLeftView addSubview:phoneLabel];
    
    //设置键盘显示类型
    phoneTextField.keyboardType = UIKeyboardTypeNumberPad;
}


@end
